package com.littleken.servlet;

import com.littleken.dao.UsersDAO;
import com.littleken.entity.Users;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/detail")
public class UsersFindById extends HttpServlet {
    private UsersDAO usersDAO = new UsersDAO();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");

        Users users = usersDAO.findById(Integer.parseInt(id));
        //System.out.println(users);////////////////////////////
        req.setAttribute("user",users);
        req.getRequestDispatcher("detail.jsp").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
